﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace view
{
    class Menu
    {
        public Commands Commands
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public Commands Commands1
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }
    
        public view.Commands getMenuChoice()
        {
            Console.Clear();
            Console.WriteLine("Välj ett kommando:");
            Console.WriteLine("1: Visa kompakt medlemslista");
            Console.WriteLine("2: Visa fullständig medlemslista");
            Console.WriteLine("3: Skapa ny medlem");
            Console.WriteLine("4: Ta bort medlem");
            Console.WriteLine("5: Uppdatera medlem");
            Console.WriteLine("6: Visa medlemsuppgifter");
            Console.WriteLine("7: Registrera ny båt");
            Console.WriteLine("8: Ta bort båt");
            Console.WriteLine("9: Uppdatera båt");
            Console.WriteLine("10: Avsluta");

            int commandIndex = getCommandIndex();
            switch (commandIndex)
            {
                case 1:
                    return Commands.getMembersBrief;
                case 2:
                    return Commands.getMembersFull;
                case 3:
                    return Commands.addMember;
                case 4:
                    return Commands.removeMember;
                case 5:
                    return Commands.updateMember;
                case 6:
                    return Commands.memberDetails;
                case 7:
                    return Commands.registerBoat;
                case 8:
                    return Commands.removeBoat;
                case 9:
                    return Commands.updateBoat;
                case 10:
                    return Commands.exit;
                default:
                    throw new InvalidOperationException();
            }
        }

        private int getCommandIndex()
        {
            int index;
            do
            {
                Console.Write("\nAnge menyval [1-10]: ");
                if (int.TryParse(Console.ReadLine(), out index) && index >= 1 && index <= 10)
                {
                    return index;
                }
                else
                {
                    Console.WriteLine("FEL! Ange ett nummer mellan 1 och 8.");
                    Console.WriteLine("Tryck ned valfri tangent för att välja på nytt...");
                }
            } while (true);
        }
    }
    public enum Commands
    {
        getMembersBrief,
        getMembersFull,
        removeMember,
        updateMember,
        memberDetails,
        registerBoat,
        removeBoat,
        updateBoat,
        addMember,
        exit
    }
}